
package rosedb.gui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.geom.RoundRectangle2D;



import riulib.gui.imagelist.FileImageList;
import rosedb.model.Logger;


/**
 *
 * @author riu
 */
public class OneRoseImageList extends FileImageList implements ComponentListener{

    private boolean isLoading;
    private Image loadPic;

    public OneRoseImageList() {
        super(Alignment.Vertical, false);
        setForceSquaredImages(false);
        addComponentListener(this);
        setForceSquaredImages(false);
        setMargin(0, 0, 0, 0);
        setPadding(0, 0, 0, 0);
    }

    public void viewRose(){
        
    }

    public synchronized void startLoading(){
        isLoading = true;
        repaint();
    }

    public synchronized void endLoading(){
        isLoading = false;
        repaint();
    }

    @Override
    public synchronized void paint(Graphics g) {
        if(isLoading){
            if(loadPic!=null){
                g.drawImage(loadPic, 0, 0, this);
            }else{
                g.drawString("Lade...", 0, 0);
            }
        }else{
            super.paint(g);
        }
    }

    public synchronized void waitTilItIsFuckingBigEnoughToPutPicturesInIt(){
        while(this.getHeight()<=0 || this.getWidth()<=0){
            try{wait();}catch(Exception e){Logger.log(e);}
        }
    }



    @Override
    public synchronized void componentResized(ComponentEvent e) {
        notifyAll();
    }
}
